 #define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

class Solution2 {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        unordered_map<int, int> hash;
        for (int i = 0; i < nums.size(); i++)
        {
            int num = target - nums[i];
            if (hash.count(num)) return { hash[num], i };
            hash[nums[i]] = i;
        }
        return { -1, -1 };
    }
};

class Solution2 {
public:
    bool CheckPermutation(string s1, string s2) {
        if (s1.size() != s2.size()) return false;

        int hash[26] = { 0 };
        for (int i = 0; i < s1.size(); i++)
            hash[s1[i] - 'a']++;

        for (int i = 0; i < s1.size(); i++)
        {
            hash[s2[i] - 'a']--;
            if (hash[s2[i] - 'a'] < 0) return false;
        }

        return true;
    }
};